#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,q;
struct node{
	int x,id;
};
node a[8005];
int b[8005];
bool cmp(node t1,node t2){
	if(t1.x!=t2.x){
		return t1.x<t2.x;
	}
	return t1.id<t2.id;
}
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i].id=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		b[a[i].id]=i;
	}
	while(q--){
		int op;
		scanf("%d",&op);
		if(op==1){
			int idx,v;
			scanf("%d%d",&idx,&v);
			int idd=a[b[idx]].id;
			for(int i=b[idx]+1;i<=n;i++){
				a[i-1].id=a[i].id;
				a[i-1].x=a[i].x;
			}
			int tt=n;
			for(int i=1;i<=n;i++){
				if(a[i].x>v){
					tt=i;
					break;
				}
				if(a[i].x==v){
					if(a[i].id>idd){
						tt=i;
						break;
					}
				}
			}
			for(int i=n;i>=tt+1;i--){
				a[i].id=a[i-1].id;
				a[i].x=a[i-1].x;
			}
			a[tt].x=v;
			a[tt].id=idd;
			for(int i=1;i<=n;i++){
				b[a[i].id]=i;
			}
		}else{
			int idx;
			scanf("%d",&idx);
			printf("%d\n",b[idx]);
		}
	}
	return 0;
}
